package com.fbms.module.system.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fbms.common.result.Res;
import com.fbms.common.result.ResBuilder;
import com.fbms.module.system.bean.entity.SysDept;
import com.fbms.module.system.bean.entity.SysRole;
import com.fbms.module.system.service.ISysDeptService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 类描述：部门
 *
 * @ClassName SysDeptController
 * @Author HappyBoy
 * @Date 2023-04-06 15:21
 **/
@RestController
@RequestMapping("/department")
@Slf4j
@RequiredArgsConstructor
public class SysDeptController {

    /**
     * 部门服务类
     */
    private final ISysDeptService deptService;


    /**
     * 获取部门列表（分页）
     * @param dept 部门信息
     * @param offset 页数
     * @param size 条数
     * @return 部门列表
     */
    public Res<IPage<SysDept>> getDeptList(@RequestParam(value = "deptInfo", required = false) SysDept dept,
                                       @RequestParam(name = "offset", defaultValue = "0")Integer offset,
                                       @RequestParam(name = "size", defaultValue = "10")Integer size){
        IPage<SysDept> page = new Page<>(offset, size);
        return ResBuilder.of(deptService.getDeptPageList(dept, page));
    }

}
